﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ChBusiness;
using System.Collections.Specialized;
using ChBusiness.User;

public partial class Index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            NameValueCollection requestParams = HttpUtility.ParseQueryString(
                HttpUtility.UrlDecode(Request.Url.Query));

            string strUser = requestParams["y"];
            string strPass = requestParams["m"];
            string strType = requestParams["SysType"];
            string UserID = requestParams["UserID"];

            if (!string.IsNullOrEmpty(strUser) && !string.IsNullOrEmpty(strPass)
                && !string.IsNullOrEmpty(strType))
            {
                //获取系统信息
                LoginInterface loginService = new LoginInterface();
                if (true == loginService.Login(strType, strUser, strPass)) 
                {
                    Session["PostOutSide"] = "1";
                    Session["SelectSys"] = strType;
                    Session["Menu"] = null;
                    Session["MenuVisible"] = requestParams["MenuVisible"];

                    Session["UserID"] = strUser.ToUpper();
                    Session["InsideUserId"] = UserID;//获取内网的登录用户id
                    Session["LoginUserName"] = UserHandle.GetUserNameByUserID(strUser.ToUpper());
                    string strUserType = UserHandle.GetNotes(strUser.ToUpper());
                    Session["UserType"] = strUserType;

                    //清空房屋建档操作位
                    Session["OperationEdit"] = null;

                    if (!string.IsNullOrEmpty(requestParams["url"]))
                    {
                        string strUrl=requestParams["url"].Replace("|","&");
                        Response.Redirect(strUrl);
                        //Server.Transfer(strUrl);
                    }
                }
            }
        }
    }
}
